using System.Collections.Generic;
using Data;
using Framework.Timer;
using Framework.UI;
using IcecreamView;
using TMPro;
using View.Component;

namespace View
{
    public class ViewGamePanel : IC_AbstractModule
    {

        [BindUIPath("Down" , "*")]
        private List<CubeItem> _cubeItems;

        [BindUIPath("LevelText")]
        private TextMeshProUGUI _levelText;
        
        private int _cameraIndex;

        public override void OnOpenView(Dictionary<string, IC_ViewData> parameters)
        {
            base.OnOpenView(parameters);
            this._cameraIndex = 2;
            foreach (CubeItem cubeItem in this._cubeItems)
            {
                cubeItem.UpdateItem();
            }

            this._levelText.text = GameManager.Instance.GameRoom.GameRoomData.LevelTitle;
            GameManager.Instance.ChangeVCam(this._cameraIndex , GameManager.Instance.GameRoom.GameRoomData.Level);
            GameManager.Instance.IsGaming = true;
            //更新场景激光
            UIManager.Instance.EventManager.SendEvent(EventCode.CheckLight);
        }

        [BindUIButton("CameraButton")]
        void OnClick_NextCamera()
        {
            if (this._cameraIndex == 3)
                this._cameraIndex = 0;
            else
                this._cameraIndex++;
            GameManager.Instance.ChangeVCam(this._cameraIndex , GameManager.Instance.GameRoom.GameRoomData.Level);
        }
        
        [BindUIButton("PauseButton")]
        void OnClick_PauseButton() { UIManager.Instance.OpenView(UIPanel.PausePanel); }

    }
}